package com.hellogood.yaohuo.server;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {
	public static String todayString() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");		
		return sdf.format(Calendar.getInstance().getTime());
	}

	public static String currentTime() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");		
		return sdf.format(Calendar.getInstance().getTime());
	}

	public static String firstDayOfMonth() {
		Date date = new Date();
		return date.getYear() + "-" + date.getMonth() + "-1";
	}

	public static Date parseDateyyyyMd(String str) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
		return sdf.parse(str);
	}

	public static Date parseDateyyyyMMdd(String str) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		return sdf.parse(str);
	}

	public String formatDateyyyyMd(Date date) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
		return sdf.format(date);
	}

	public String formatDateyyyyMMdd(Date date) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		return sdf.format(date);
	}	
}
